//
//  DTMemeberCell.m
//  Objective-cDemo
//
//  Created by ShareAnimation on 2019/8/6.
//  Copyright © 2019 爱丽丝的梦境. All rights reserved.
//

#import "DTMemeberCell.h"
#import "Masonry.h"
@interface DTMemeberCell ()

@property (strong, nonatomic) UIImageView *contentImageView;
@property (strong, nonatomic) UILabel *nameLabel;

@end
@implementation DTMemeberCell

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        
        [self setupViews];
    }
    return self;
}

- (void)setupViews {
    UIImageView *contentImageView = [UIImageView new];
    self.contentImageView = contentImageView;
    contentImageView.contentMode = UIViewContentModeScaleAspectFit;
    contentImageView.layer.cornerRadius = 8;
    contentImageView.layer.masksToBounds = true;
//    contentImageView.image = [UIImage imageNamed:@"222222"];
    [self.contentView addSubview:contentImageView];
    [contentImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(contentImageView);
        make.width.height.equalTo(@60);
    }];
    
    UILabel *nameLabel = [UILabel new];
    self.nameLabel = nameLabel;
    nameLabel.textAlignment = NSTextAlignmentCenter;
//    nameLabel.text = @"alsjdof";
    [self.contentView addSubview:nameLabel];
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.right.equalTo(self.contentView);
        make.top.equalTo(contentImageView.mas_bottom);
    }];
}

- (void)bindModel:(DTMemberCellModel *)model {
    switch (model.cellType) {
        case DTMemberCellTypeAdd:
        {
            self.contentImageView.image = [UIImage imageNamed:@"add_member"];
            self.nameLabel.text = @"   ";
        }
            break;
        case DTMemberCellTypeRemove:
        {
            self.contentImageView.image = [UIImage imageNamed:@"delete_member"];
            self.nameLabel.text = @"   ";
        }
            break;
        case DTMemberCellTypeNormal:
        {
            self.contentImageView.image = [UIImage imageNamed:model.headUrl];
            self.nameLabel.text = model.name;
        }
            break;
            
        default:
            break;
    }
}
@end
